//
//  LastBalanceTableViewCell.m
//  EasyToTesco2.0
//
//  Created by 袖手旁觀 on 16/6/23.
//  Copyright © 2016年 EasyToTesco. All rights reserved.
//

#import "LastBalanceTableViewCell.h"

#define  Margin 8


@implementation LastBalanceTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self loadLastBalanceUI];
    }
    return self;
}

- (void)loadLastBalanceUI {
    UILabel *moreLabel = [[UILabel alloc] init];
    moreLabel.textColor = DEFAULT_COLOR;
    moreLabel.text = @"注:派现金额不得超过 5,000,三个工作日内到账,节假日顺延,请确保卡号无误";
    moreLabel.numberOfLines = 0;
    moreLabel.font = [UIFont systemFontOfSize:13];
    [self.contentView addSubview:moreLabel];
    
    [moreLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.contentView.mas_centerX);
        if (iPhone5 || iPhone6) {
            make.top.equalTo(self.contentView.mas_top).with.offset(Margin * 3);
        } else {
            make.top.equalTo(self.contentView.mas_top).with.offset(Margin * 10);
        }
        make.width.mas_equalTo(WIDTH * 0.6);
        make.height.mas_equalTo(40);
    }];
    
    UIButton * immediatePay = [[UIButton alloc] init];
    [immediatePay setTitle:@"立即支付" forState:UIControlStateNormal];
    immediatePay.backgroundColor = DEFAULT_COLOR;
    immediatePay.titleLabel.font = FONT(15);
    [immediatePay setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    immediatePay.layer.cornerRadius = 5;
    immediatePay.layer.masksToBounds = YES;
    [immediatePay addTarget:self action:@selector(didClickButton:) forControlEvents:UIControlEventTouchUpInside];
    [self.contentView addSubview:immediatePay];
    
    [immediatePay mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(moreLabel.mas_bottom).with.offset(Margin * 2);
        make.centerX.equalTo(self.contentView.mas_centerX);
        make.width.mas_equalTo(moreLabel.mas_width);
        make.height.mas_equalTo(30);
    }];
}

- (void)didClickButton:(UIButton *)immediatePayButton {
    if ([self.delegate respondsToSelector:@selector(didClickImmediatePayButton:)]) {
        [self.delegate didClickImmediatePayButton:immediatePayButton];
    }
}

@end
